package com.abbas.smartCity.ui.govservice;

import com.abbas.smartCity.R;
import com.abbas.smartCity.adapter.BannerImageAdapter2;
import com.abbas.smartCity.adapter.GovBannerAdapter;
import com.abbas.smartCity.base.BaseActivity;
import com.abbas.smartCity.bean.gov.GovAppealCategoryTypeBean;
import com.abbas.smartCity.bean.gov.GovHomeBannerBean;
import com.abbas.smartCity.retroft.ICallback;
import com.abbas.smartCity.view.MListView;
import com.youth.banner.Banner;
import com.youth.banner.indicator.CircleIndicator;

import java.util.List;
import java.util.stream.Collectors;

import retrofit2.Call;

public class GovSerMainActivity extends BaseActivity {

    private Banner<GovHomeBannerBean.DataBean, BannerImageAdapter2<String>> banner;
    private Banner<GovAppealCategoryTypeBean.RowsBean, GovBannerAdapter> serverTypeBanner;

    private MListView lv;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_gov_ser_main;
    }

    @Override
    protected String setCustomTitle() {
        return "政府服务热线";
    }

    @Override
    protected void initView() {
        banner = findViewById(R.id.banner);
        serverTypeBanner = (Banner) findViewById(R.id.serverTypeBanner);
        lv = (MListView) findViewById(R.id.lv);

    }

    @Override
    protected void initData() {
        //轮播图加载
        api.getGovHomeBanner().enqueue(new ICallback<GovHomeBannerBean>() {
            @Override
            public void onSuccess(Call<GovHomeBannerBean> call, GovHomeBannerBean data) {
                final List<GovHomeBannerBean.DataBean> govHomeBannerData = data.getData();

                banner.setAdapter(new BannerImageAdapter2<>(
                        govHomeBannerData.stream()
                                .map(GovHomeBannerBean.DataBean::getImgUrl)
                                .collect(Collectors.toList())
                )).setIndicator(new CircleIndicator(GovSerMainActivity.this))
                        .start();
            }
        });

        //诉求分类
        api.getAppealCategory().enqueue(new ICallback<GovAppealCategoryTypeBean>() {
            @Override
            public void onSuccess(Call<GovAppealCategoryTypeBean> call, GovAppealCategoryTypeBean data) {
                final List<GovAppealCategoryTypeBean.RowsBean> rows = data.getRows();
                serverTypeBanner.setAdapter(new GovBannerAdapter(rows))
                        .setIndicator(new CircleIndicator(GovSerMainActivity.this))
                        .isAutoLoop(false);
            }
        });

        //我的诉求

    }

    @Override
    protected void initEvent() {

    }
}